package com.uikoo9.manage.y.model;

import java.util.List;
import java.util.Map;

import com.jfinal.plugin.activerecord.Model;
import com.uikoo9.manage.y.util.SqlKit;
import com.uikoo9.plugin.QLogger1;
import com.uikoo9.util.core.annotation.QTable;
import com.uikoo9.util.core.data.QStringUtil;

/**
 * YIsayModel<br>
 * id	id<br>
 * y_isay_content	内容<br>
 * y_isay_status	<br>
 * cdate	创建时间<br>
 * cuser_id	input_id<br>
 * cuser_name	input_name<br>
 * y_isay_title	标题<br>
 * @author qiaowenbin
 */
@QTable("t_y_isay")
@SuppressWarnings("serial")
public class YIsayModel extends Model<YIsayModel>{
	
	public static final YIsayModel dao = new YIsayModel();
	
	/**
	 * find all
	 * @return
	 */
	public List<YIsayModel> findAll(){
		return findAll(null);
	}
	
	/**
	 * find all by order
	 * @param order
	 * @return
	 */
	public List<YIsayModel> findAll(String order){
		StringBuilder sb = new StringBuilder("select * from t_y_isay ");
		if(QStringUtil.isEmpty(order)){
			return dao.find(sb.append("order by id desc").toString());
		}else{
			return dao.find(sb.append(order).toString());
		}
	}

    /**
    * find all by param
    * @param param
    * @return
    */
    public List<YIsayModel> find(Map<String,Object[]> querytype,Map<String,Object> param){
        String sql="select * from t_y_isay where 1=1";
        SqlKit s = new SqlKit();
        if(param!=null && !param.isEmpty()){
            if(querytype != null){
                s.buildSQL(querytype,param);
            }else {
                s.buildSQL(param);
            }
            sql+= s.getSql();
        }
        QLogger1.getLogger().debug(sql);
        return  dao.find(sql,s.getParamArray());
    }

    /**
    * find all by ID
    * @param name
    * @return
    */
    public List<YIsayModel> findByName(String name){
        return  dao.find("select * from t_y_isay where name = ?",name);
    }
	
}
